/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef DEVICE_PROFILE_AGENT_H
#define DEVICE_PROFILE_AGENT_H

#include "distributed_device_profile_client.h"

#include "profile_change_listener_stub.h"

namespace OHOS {
namespace Storage {
namespace DistributedFile {

using namespace DistribituedDeviceProfile::TrustDeviceProfile;
enum class SwitchState {
    OFF_STATE,
    ON_STATE,
    MAX_STATE
};

class DeviceProfileAgent {
    DECLARE_SINGLETON(DeviceManagerAgent);
public:
    bool GetDeviceSwitchState(const std::string &udid, SwitchState &switchState);
    bool SetDeviceSwitchState(const std::string &udid, const SwitchState switchState);
    void SubscribeProfileEvent(const std::string &udid);
    void UnSubscribeProfileEvent(const std::string &udid);

    class SubScribeDPChangeListener : public DistributedDeviceProfile::ProfileChangeListenerStub {
    public:
        SubScribeDPChangeListener();
        ~SubScribeDPChangeListener();
        int32_t OnTrustDeviceProfileAdd(const TrustDeviceProfile& profile) override;
        int32_t OnTrustDeviceProfileDelete(const TrustDeviceProfile& profile) override;
        int32_t OnTrustDeviceProfileUpdate(const TrustDeviceProfile& oldProfile,
            const TrustDeviceProfile& newProfile) override;
        int32_t OnTrustDeviceProfileActive(const TrustDeviceProfile& profile) override;
        int32_t OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile) override;
        int32_t OnDeviceProfileAdd(const DeviceProfile& profile) override;
        int32_t OnDeviceProfileDelete(const DeviceProfile& profile) override;
        int32_t OnDeviceProfileUpdate(const DeviceProfile& oldProfile, const DeviceProfile& newProfile) override;
        int32_t OnServiceProfileAdd(const ServiceProfile& profile) override;
        int32_t OnServiceProfileDelete(const ServiceProfile& profile) override;
        int32_t OnServiceProfileUpdate(const ServiceProfile& oldProfile, const ServiceProfile& newProfile) override;
        int32_t OnCharacteristicProfileAdd(const CharacteristicProfile& profile) override;
        int32_t OnCharacteristicProfileDelete(const CharacteristicProfile& profile) override;
        int32_t OnCharacteristicProfileUpdate(const CharacteristicProfile& oldProfile,
            const CharacteristicProfile& newProfile) override;

    private:
        std::mutex mutex_;
        std::unordered_map<std::string, SubscribeInfo> subscribeInfoCache_;
    }
};
} // namespace DistributedFile
} // namespace Storage
} // namespace OHOS
#endif // DEVICE_PROFILE_AGENT_H
